package regex;

public class Demo02_regex {
    public static void main(String[] args) {
        //extracted();

        //extracted1();

        //extracted2();

        //String regex = "[a-d[m-p]]";//a到d，m到p

        //String regex = "[a-z&&[def]]";// a-z 跟def的交集

        //String regex = "[a-z&&[^bc]]";//除了b和c的a-z

        //String regex = "[a-z[^m-p]]";//a-z中除了m-p

    }

    private static void extracted2() {
        String regex = "[a-zA-Z]";//a-z或者A-Z中的任意一个单个字符
        System.out.println("a".matches(regex));
        System.out.println("b".matches(regex));
        System.out.println("c".matches(regex));
        System.out.println("@".matches(regex));
        System.out.println("%".matches(regex));
        System.out.println("1".matches(regex));
    }

    private static void extracted1() {
        String regex = "[^abc]";//代表除了abc之外的其他字符
        System.out.println("a".matches(regex));
        System.out.println("b".matches(regex));
        System.out.println("c".matches(regex));
        System.out.println("@".matches(regex));
        System.out.println("%".matches(regex));
        System.out.println("1".matches(regex));
    }

    private static void extracted() {
        String regex = "[abc]";//[...]代表单个字符：a、b或c
        System.out.println("a".matches(regex));
        System.out.println("b".matches(regex));
        System.out.println("c".matches(regex));
        System.out.println("@".matches(regex));
        System.out.println("%".matches(regex));
    }
}
